package com.apestech.framework.xml.plugin.node;

import com.apestech.framework.xml.plugin.modul.SpecialField;
import com.apestech.framework.xml.pub.core.ElementUtil;
import org.dom4j.Element;

import java.util.List;

/**
 * @author hup
 * @create 2019-02-13-15:55
 */
public class NodeSpecialField extends ElementUtil {
    private Element node;
    private SpecialField specialField;

    public NodeSpecialField(Element node){
        this.node=node;
    }

    public void getAllField() throws Exception {
        List<?> list=node.content();
        int len=list.size();
        for(int i=0; i<len; i++){
            String scalss=list.get(i).getClass().getName();
            if(scalss.equals("org.dom4j.tree.DefaultElement")){
                Element eml = (Element) list.get(i);
                if(specialField==null) specialField=new SpecialField();
                specialField.addField(eml.getName(), getNodeAttr(eml).getJSONObject("attrNode"));
            }
        }
    }

    public SpecialField getSpecialField() {
        return specialField;
    }
}
